import React from 'react'
import { observer, inject } from 'mobx-react'
import './errorPop.scss'

@inject('UserStore')
@observer
class ErrPop extends React.Component {
  constructor(props) {
    super()
    this.state = {}
  }
  componentDidMount() {
    this.setTimer()
  }
  componentWillMount() {
    // clearTimeout(this.timer)
  }

  setTimer() {
    let _this = this
    _this.timer = setTimeout(() => {
      _this.props.UserStore.setErrorMsg(false, '')
    }, 3000)
  }
  render() {
    const { errorPop, errorMsg } = this.props.UserStore

    function createMarkup() {
      return { __html: errorMsg }
    }
    return (
      <div>
        {errorPop && (
          <div className="error-pop-page">
            <div className="error-pop-bkg" />
            <div className="error-pop-dec">
              {/*<span className='dec-main'>{errorMsgPro}</span>*/}
              <span
                className="dec-main"
                dangerouslySetInnerHTML={createMarkup()}
              />
            </div>
          </div>
        )}
      </div>
    )
  }
}

export default ErrPop
